import { AuthState } from "@/redux/interface";
import * as types from '@/redux/mutation-types';
import { Draft, produce } from "immer";
import { Action } from "redux";

const authState: AuthState = {
    authButtons: {},
    authRouter: []
}
interface SET_AUTH_BUTTONS extends Action {
    type: typeof types.SET_AUTH_BUTTONS,
    authButtons: {}
}
interface SET_AUTH_ROUTER extends Action {
    type: typeof types.SET_AUTH_ROUTER,
    authRouter: []
}
// menu reducer
type ActionType = SET_AUTH_BUTTONS | SET_AUTH_ROUTER;
const auth = (state: AuthState = authState, action: ActionType) => {
    return produce(state, (draftState: Draft<AuthState>) => {
        switch (action.type) {
            case types.SET_AUTH_BUTTONS:
                draftState.authButtons = action.authButtons;
                break;
            case types.SET_AUTH_ROUTER:
                draftState.authRouter = action.authRouter;
                break;
            default:
                break;
        }
    })
}

export default auth;